﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DAL;
using IFactory;

namespace BLL
{
    public class UserMonthPlanDetailManager
    {
        DataStructure dllDataStructure = new DataStructure();


        /// <summary>
        /// 预定义查询条件
        /// </summary>
        public enum field
        {
            Id,
            MonthPlanId,
            MonthDetailPlanId,

            StartTime,
            CompleteTime,
            WorkItem,
            MasterDepartment,
            MasterPeople,
            SlaveDepartment,
            SlaveDepartmentDuty,
            EvaluatePeople,
            PlanSendState,
            IsConsensus,
            Remart,
            IsDelete
        }


        /// <summary>
        /// 添加员工月分解方法带事务
        /// </summary>
        /// <param name="_value">传入的参数集合</param>
        /// <returns>影响行数</returns>
        /// <author>grokyao</author>
        /// <date>2009-2-18</date>
        public int addWithTransaction(List<object[]> _valueList)
        {
            string _spName = "Insert_UserMonthPlanDetail";
            return dllDataStructure.getAffectRowsWithTransaction(_spName, _valueList);
        }


        /// <summary>
        /// 删除月分解方法带事务
        /// </summary>
        /// <param name="_field">枚举字段类型</param>
        /// <param name="_value">传入的参数值</param>
        /// <returns>影响行数</returns>
        /// <author>grokyao</author>
        /// <date>2009-3-31 </date>
        public int delWithTransaction(List<object[]> _valueList)
        {
            string _spName = "Del_UserMonthPlanDetail";
            return dllDataStructure.getAffectRowsWithTransaction(_spName, _valueList);
        }


        /// <summary>
        /// 根据枚举字段编辑方法
        /// </summary>
        /// <param name="_field">枚举字段类型</param>
        /// <param name="_value">传入的值类型</param>
        /// <returns>影响的行数</returns>
        /// <author>gzz</author>
        /// <date>2009-1-5 </date>
        public int edit(string _field, object[] _value)
        {
            string _spName = "Update_UserMonthPlanDetail";
            if (_field == "Id")
            {
                _spName += "ById";
            }

            return dllDataStructure.getAffectRows(_spName, _value);
        }


        /// <summary>
        /// 根据一个字段查询
        /// </summary>
        /// <param name="_field">字段名称</param>
        /// <param name="_value">参数值</param>
        /// <returns>DataTable</returns>
        /// <author>gzz</author>
        /// <date>2009-1-5 </date>
        public DataTable get(string _field, object[] _value)
        {
            string _spName = "Select_UserMonthPlanDetail";
            if (_field == "MonthPlanId")
            {
                _spName += "ByMonthPlanId";
            }
            if (_field == "Id")
            {
                _spName += "ById";
            }
            return dllDataStructure.getDataTable(_spName, _value);
        }


        /// <summary>
        /// 根据枚举选择删除，返回影响行数
        /// </summary>
        /// <param name="_field">枚举字段类型</param>
        /// <param name="_value">传入的参数值</param>
        /// <returns>影响行数</returns>
        /// <author>gzz</author>
        /// <date>2009-1-5 </date>
        public int del(string _field, object[] _value)
        {
            string _spName = "Del_UserMonthPlanDetail";
            if (_field == "Id")
            {
                _spName += "ById";
            }
            return dllDataStructure.getAffectRows(_spName, _value);
        }
    }
}
